package cn.dancepeak.service.impl;

import cn.dancepeak.domain.Student;
import cn.dancepeak.mapper.StudentMapper;
import cn.dancepeak.service.IStudentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Slf4j
@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)//只读
public class StudentServiceImpl implements IStudentService {
    @Autowired
    private StudentMapper studentMapper;
    @Override
    public List<Student> getStudent() {
        return studentMapper.selectAll();
    }

    @Override
    @Transactional
    public void addStudent(Student student) {

        studentMapper.add(student);
    }

    @Override
    @Transactional
    public void updateStudent(Student student) {
        studentMapper.update(student);
    }

    @Override
    @Transactional
    public void deleteStudentById(Long id) {

        studentMapper.delete(id);
    }
}
